#include <bits/stdc++.h>
// 2025/05/17
// tag: LCA
// Author: Forever
using namespace std;
#define MAXN 500001
#define LOG_MAX 21

int n, m, s;
vector<int> edge[MAXN];

int up[MAXN][LOG_MAX], depth[MAXN];

void preprocess(int u, int parent)
{
    up[u][0] = parent;
    for (int k = 1; k < LOG_MAX; ++k)
        up[u][k] = up[up[u][k - 1]][k - 1];
    for (int i = 0; i < edge[u].size(); ++i) {
        int v = edge[u][i];
        if (v != parent) {
            depth[v] = depth[u] + 1;
            preprocess(v, u);
        }
    }
}

int lca(int u, int v)
{
    if (depth[u] < depth[v])
        swap(u, v);
    for (int k = LOG_MAX - 1; k >= 0; --k)
        if (depth[u] - (1 << k) >= depth[v])
            u = up[u][k];
    if (u == v)
        return u;
    for (int k = LOG_MAX - 1; k >= 0; --k) 
        if (up[u][k] != up[v][k]) 
            u = up[u][k], v = up[v][k];

    return up[u][0];
}


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i < n; ++i) {
        int u, v;
        cin >> u >> v;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    preprocess(1, 1);
    for (int i = 1; i <= m; ++i) {
        int x, y, z;
        cin >> x >> y >> z;
        int t, t1 = lca(x, y), t2 = lca(y, z), t3 = lca(x, z);
        if (t1 == t2)
            t = t3;
        else if (t1 == t3)
            t = t2;
        else if (t2 == t3)
            t = t1;
        cout << t << " " << depth[x] + depth[y] + depth[z] - depth[t1] - depth[t2] - depth[t3] << endl;
    }
    return 0;
}